import logging

import allure
from selenium.common import *
from key_word.key_word import KeyWord
from locator.login import *


# 继承工具类
class LoginPage(KeyWord):
    # 打开网页
    def get_url(self, url):
        with allure.step("打开网页"):
            self.open_url(url)

    # 输入账号
    def send_username(self, login_username):
        with allure.step("输入账号"):
            self.send_content(page_login_username[0], page_login_username[1], login_username)

    # 输入密码
    def send_password(self, login_password):
        with allure.step("输入密码"):
            self.send_content(page_login_password[0], page_login_password[1], login_password)

    # 拖动解锁
    def drag_lock(self, xoffset, yoffset):
        with allure.step("拖动解锁"):
            self.drag_and_drop(page_login_block[0], page_login_block[1], xoffset, yoffset)

    # 点击登录按钮
    def click_btn(self):
        with allure.step("点击登录"):
            self.click_el_until_visibility(*page_login_btn)
